Skip to content

Add Node.fromGlbStream factory for Stream<List<int>> input#129

Open
aki1770-del wants to merge 1 commit into
bdero:masterfrom
aki1770-del:feat/node-from-glb-stream
Open

Add Node.fromGlbStream factory for Stream<List<int>> input#129
aki1770-del wants to merge 1 commit into
bdero:masterfrom
aki1770-del:feat/node-from-glb-stream

Conversation

@aki1770-del
Copy link
Copy Markdown

Sibling to the existing Node.fromGlbBytes / Node.fromGlbAsset factories, accepting a Stream<List<int>> source instead of a materialised Uint8List or asset path.

Use cases this opens up:

  • HTTP response bodies via package:http (response.stream)
  • dart:io File.openRead() pipes
  • Websocket frame sources
  • Any caller with a chunked byte source but no full buffer up-front

Implementation drains the stream into a BytesBuilder and delegates to fromGlbBytes — peak memory equals the full GLB size, matching fromGlbBytes semantics. True incremental parsing of the GLB container is intentionally out of scope for this factory.

The factory accepts Stream<List<int>> (Dart-idiomatic; matches dart:io and package:http conventions); Stream<Uint8List> callers work transparently since Uint8List implements List<int>.

On the test approach: existing runtime-importer tests like runtime_importer_byte_comparison_test.dart require flutter_gpu. The new test guards the stream-collection code path directly (without flutter_gpu) so it remains runnable in pure-dart:test CI. Happy to migrate to a flutter_gpu-enabled test instead if that fits the test suite layout better.

AI-assisted — authored with Claude, reviewed by Komada.

Sibling to the existing Node.fromGlbBytes / Node.fromGlbAsset
factories, accepting a Stream<List<int>> source instead of a
materialised Uint8List or asset path.

Use cases this opens up:
- HTTP response bodies via `package:http` (response.stream)
- `dart:io` File.openRead() pipes
- Websocket frame sources
- Any caller with a chunked byte source but no full buffer up-front

Implementation drains the stream into a BytesBuilder and delegates
to fromGlbBytes — peak memory equals the full GLB size, matching
fromGlbBytes semantics. True incremental parsing of the GLB
container is intentionally out of scope for this factory.

The factory accepts Stream<List<int>> (Dart-idiomatic; matches
dart:io and package:http conventions); Stream<Uint8List> callers
work transparently since Uint8List implements List<int>.

Test covers stream-collection contract directly without flutter_gpu
pipeline instantiation (which is unavailable in pure dart:test):
chunked input produces byte-identical output for fcar.glb;
Stream<Uint8List> upcast handles correctly; empty stream produces
empty bytes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant